<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:useBean id="edittingOrg"
	class="team02.server.bean.OrganizationBean" scope="page"></jsp:useBean>
<jsp:useBean id="edittingOrgAdmin" class="team02.server.bean.UserBean"
	scope="page"></jsp:useBean>
<jsp:setProperty property="*" name="edittingOrg" />
<link href="${pageContext.request.contextPath}/css/org_manager.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/add_new_org.css"
	rel="stylesheet" type="text/css" />

<script type="text/javascript" lang="javascript"
	src="${pageContext.request.contextPath}/js/org_edit.js">
</script>
<script type="text/javascript">
	function convert_date() {
		if(!checkpassword())return false;
		var str = document.forms["form"]["expired"].value;
		var dt = new Date(str);
		document.forms["form"]["expiredDate"].value = dt.getTime();
	}

	function error(){
		alert("団体追加できませんでした。");
	}
	function checkpassword() {
		if (document.form.password.value==""||document.form.password.value != document.form.confirmPassword.value) {
			alert("パスワードと確認パスワードが違う");
			return false;
		}

		return true;
	}
</script>
<%
//権限をチェック
if(userBean.getAccessLevel()!=1){
	response.sendRedirect("404.html");
	return;
}
%>

<c:if test="${edittingOrg.name != null}">
	<c:set var="insertResult" value="<%=edittingOrg.insert()%>"></c:set>
	<c:choose>
		<c:when test="${0 == insertResult}">
		<%
				response.sendRedirect("org_manager.t02");
		 %>
			
		</c:when>
		<c:otherwise>

			<script type="text/javascript" lang="javascript">
				error();
			</script>
			
		</c:otherwise>
	</c:choose>
</c:if>

<div class="menu1"><%@include file="/jsputils/menu.jsp"%>
	<div class = "greeting_message">
		<%@include file="/jsputils/greeting.jsp"%>
	</div>
</div>
<div class="container">
<form action="" method="post" name="form" id="add_org">
	<div class="menu">
		<p class="menu_label">新規団体を追加</p>
	</div>
	<table class="content_table">
		<tr>
			<td>
				<p class="label">団体名 ：</p>
			</td>
			<td>
				<p class="input">
					<input type="text" required="required" name="name" value=""
						placeholder=" 例. Hanoi university of sicenes and technologies" />
				</p>
			</td>
		</tr>
		<tr>
			<td>
				<p class="label">Alias ：</p>
			</td>
			<td>
				<p class="input">
					<input type="text" required="required" name="alias"
						placeholder="例. bachkhoa" />
				</p>
			</td>
		</tr>
		<tr>
			<td>
				<p class="label">期限日：</p>
			</td>
			<td>
				<p class="input">
					<input type="date" name="expired" required="required"
						class="{validate:{required:true, date:true}}" name="expired"
						placeholder="例. 2013/6/6" />
					<input type="hidden" name="expiredDate"/>
				</p>
			</td>
		</tr>
				<tr>
			<td>
				<p class="label">アドレス：</p>
			</td>
			<td>
				<p class="input">
					<input type="text" name="address" required="required"
						placeholder="例. No 01 - Dai Co Viet - Hai Ba Trung - Hanoi" />
				</p>
			</td>
		</tr>

		<tr>
			<td>
				<p class="label">モバイル</p>
			</td>
			<td>
				<p class="input">
					<input type="tel" name="phone"  required="required" placeholder="例. 0439999999" />
				</p>
			</td>
		</tr>

		
		<tr>
			<td>
				<p class="label">管理者名 ：</p>
			</td>
			<td>
				<p class="input">
					<input type="text" required="required" name="adminname"
						placeholder="例. hust" />
				</p>
			</td>
		</tr>

		<tr>
			<td>
				<p class="label">ログイン名 ：</p>
			</td>
			<td>
				<p class="input">
					<input type="text" required="required" name="username"
						placeholder="例. HUST.VN" />
				</p>
			</td>
		</tr>

		<tr>
			<td>
				<p class="label">パスワード：</p>
			</td>
			<td>
				<p class="input">
					<input type="password" required="required" name="password" />
				</p>
			</td>
		</tr>

		<tr>
			<td>
				<p class="label">パスワード再入力 ：</p>
			</td>
			<td>
				<p class="input">
					<input type="password" required="required" name="confirmPassword" />
				</p>
			</td>
		</tr>

		<tr>
			<td>
				<p class="label">メール：</p>
			</td>
			<td>
				<p class="input">
					<input type="email" name="email" required="required" placeholder="例. abc@gmail.com" />
				</p>
			</td>
		</tr>
		<tr>
			<td>
				<p class="label">説明：</p>
			</td>
			<td>
				<p class="input">
					<input type="text" name="description" required="required"
						placeholder="例. The bigest university in Vietnam" />
				</p>
			</td>
		</tr>
		
		<tr>
			<td>
				<p class="submit" style="text-align: right;">
					<input type="submit" formaction="" name="btn" value="保存" onclick="return convert_date()"/>
				</p>
			</td>
			<td style="text-align: left;">
				<a href="org_manager.t02">キャンセル</a>
			</td>
		</tr>
	</table>
</form>
</div>